<template>
    <div></div>
</template>

<script>
/**
 * 该组件不做任何事，仅用于友好跳转
 */
export default {
    name: "black",
    data() {
        return {
            maxRetries: 3,
            retryCount: 0
        }
    },
    created() {
        this.redirectToTarget()
    },
    methods: {
        redirectToTarget() {
            const path = this.$route.query.willPath || '/'
            console.log('black path', path)

            setTimeout(() => {
                try {
                    this.$router.push({ path }).catch(err => {
                        console.error('路由跳转失败:', err)
                        this.handleRedirectError()
                    })
                } catch (error) {
                    console.error('路由跳转出错:', error)
                    this.handleRedirectError()
                }
            }, 50)
        },
        handleRedirectError() {
            if (this.retryCount < this.maxRetries) {
                this.retryCount++
                console.log(`重试第 ${this.retryCount} 次`)
                setTimeout(() => {
                    this.redirectToTarget()
                }, 200 * this.retryCount)
            } else {
                console.error('多次重试后仍然失败，跳转到首页')
                this.$router.push('/')
            }
        }
    }
}
</script>

<style scoped>

</style>
